/**
 * (C) 2007 - Boston University
 * 	Contact: Michael Ocean 

  This work is a part of the larger snBench project.  Information
  can be found at: http://csr.bu.edu/snbench

  This program is free software; you can redistribute it and/or
  modify it under the terms of Version 2 of the GNU General Public 
  License.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
package snobject;


import sxe.sensors.GenericSensor;

/**
 * @author Michael
 *
 * snSensor
 * snobject / snSensor.java
 * 
 * The snSensor abstracts a particular data source in the snBench.  
 * 
 * In its unbound state, it describes the features some arbitrary sensor
 * should have.  In its bound state it describes a particular sensor.
 *  
 */

public class snSensor extends snObject {
	private GenericSensor gs;
	private byte[] body;

	/*
	public snSensor(java.io.InputStream stream) 
	throws java.io.IOException {
		body = http.Client.drainToByteArray(stream);
	}

	public snSensor(String string) {
		body = string.getBytes();
	}

	public snSensor(byte[] buffer) {
		body = buffer;
	}
	*/
	
	public snSensor(GenericSensor s){
		super();
		
		gs = s;
		content = s;
	}
	
	public String getXmlMimeType() { return snobject.MimeTypes.SENSOR; }
	public String getWebMimeType() { return "text/plain"; }
	public String getBinaryMimeType() { return "text/plain"; }
	
	public void xmlWrite(java.io.OutputStream out, int depth) throws java.io.IOException {		
		step.Node.Indent(out, depth);
		body = gs.GetInfoXML().getBytes();
		out.write(body);
	}
	public void webWrite(java.io.OutputStream out, int depth) throws java.io.IOException {
		xmlWrite(out,depth);
	}
	public void binaryWrite(java.io.OutputStream out) throws java.io.IOException {
		xmlWrite(out,0);
	}

	public String getSensorType() { 
		return gs.getType();
	}

	public String getSensorID() {
		return gs.getID();
	}

	public String toString(){
		return "[" + getSensorType() + "/" + getSensorID() + "]";
	}
}
